package io.geekidea.boot.config.properties;

import io.geekidea.boot.util.YamlUtil;
import lombok.Data;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 框架公共配置
 *
 * @author geekidea
 * @date 2023/12/03
 **/
@Data
@Component
@ConfigurationProperties(prefix = "boot")
public class BootProperties {

    /**
     * 排除的路径
     */
    private List<String> excludePaths;
    private FormConfig form;
    private String domain;
    private AssistConfig assistant;

    public void setExcludePaths(List<String> excludePaths) {
        this.excludePaths = YamlUtil.parseListArray(excludePaths);
    }

    @Data
    public static class FormConfig {

        private boolean enableFormDefCache;
        private boolean loadFormByLocal;
        private boolean enableLog;
        private Boolean monitorFileChange;
        private I18n i18n;
        private Map<String, String> alias;
        private ChartConfig chartConfig;

        @Data
        public static class I18n {
            private boolean enableI18nConfigReload = true;
            private String base;
            private Integer cacheSeconds = 1;
        }
    }

    @Data
    public static class AssistConfig {
        private String systemText;
    }

    @Data
    public static class ChartConfig {
        private Long formId;
        private String selectItems;
        private String filters;
    }
}
